from twisted.application import service
from twisted.internet import reactor, defer
from twisted.plugin import getPlugins

from pyhnode import pyhnodeservice, interfaces, net, config

def PyHNodeServiceMaker(conffile):
    netmodules = getPlugins(interfaces.INetPlugin, net)
    config.conf = config.cfg(conffile)
    s = service.MultiService()
    parser = pyhnodeservice.PyHNodeService()
    for i in netmodules:
        n = i.getName()
        if n in config.conf.get('net', 'protocols').split(','):
            x = i.makeService(parser)
            x.setServiceParent(s)
    return s
